﻿Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlTypes
Imports Microsoft.SqlServer.Server

Partial Public Class UserDefinedFunctions
    <Microsoft.SqlServer.Server.SqlFunction()> _
    Shared Function MFBreakFileNameWithPathForFilePath(ByVal FileNameWithPath As SqlString) As SqlString
        Dim _sFileNameWithPath As String = FileNameWithPath.ToString.Trim

        Try
            Return System.IO.Path.GetDirectoryName(_sFileNameWithPath).Trim & "\"
        Catch sqlex As SqlException
            Throw New Exception("FileName: " & _sFileNameWithPath, sqlex)
        Catch ex As Exception
            Throw New Exception("FileName: " & _sFileNameWithPath, ex)
        End Try

        Return SqlString.Null
    End Function
End Class
